
package com.scalar.chiptrack.tags;

import javax.servlet.jsp.JspException;

import com.scalar.chiptrack.utils.ConfigManager;

/**
 *
 */
public class IntegTag extends org.apache.struts.taglib.html.ErrorsTag
{

    private String mType = null;

    public String getType()
    {
        return mType;
    }

    public void setType( String type )
    {
        mType = type;
    }


    private String mModule = null;

    public String getModule()
    {
        return mModule;
    }

    public void setModule( String module )
    {
        mModule = module;
    }

    public int doStartTag() throws JspException
    {
        int returnType = SKIP_BODY;
        String integType = null;

        if( mModule != null )
        {
            mModule = mModule.toLowerCase();

            //System.out.println( "module = " + mModule + ", integType = " + integType + ", type = " + mType );

            if( mModule.startsWith( "fin" ) == true )
            {
                integType = ConfigManager.getFinanceIntegrationType();
                if( ( integType != null ) && ( integType.equalsIgnoreCase( mType ) == true ) )
                {
                    returnType = EVAL_BODY_INCLUDE;
                }
            }
            else if( mModule.startsWith( "sales" ) == true )
            {
                integType = ConfigManager.getSalesIntegrationType();
                if( ( integType != null ) && ( integType.equalsIgnoreCase( mType ) == true ) )
                {
                    returnType = EVAL_BODY_INCLUDE;
                }
            }
        }

        return returnType;
    }

}